handle PEP 639 License-Expression in test metadata#46
Merged
thrau merged 1 commit intolocalstack:mainfrom Apr 2, 2026
Merged
Conversation
pytest >= 9.0 is built with setuptools >= 77, which emits License-Expression instead of the legacy License header. Use .get() to support both old-style and PEP 639 metadata. AI-assisted: OpenCode (Claude Opus 4.6)
Contributor
Author
|
I didn't go as far as upgrading pytest, but on a local test I can confirm the entire test suite works with pytest-9.0.2 |
thrau
approved these changes
Apr 2, 2026
Member
thrau
left a comment
There was a problem hiding this comment.
nice catch Alessio @nolith, thanks for the contribution!
this change looks good to me. i would also have been ok with just removing the assert. but this makes it much clearer. i was vaguely aware that the license metadata field had been changed, but hadn't connected the dots to plux, so thanks!
13 tasks
github-merge-queue bot
pushed a commit
to NixOS/nixpkgs
that referenced
this pull request
Apr 3, 2026
test_resolve_distribution_information fails with pytest >= 9.0.2 because pytest now uses PEP 639 License-Expression metadata instead of the legacy License field. Upstream pins pytest==8.4.1 in CI and has not encountered this yet. Upstream fix: localstack/plux#46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
test_resolve_distribution_informationassertsdist.metadata["License"] == "MIT"against the installed pytest package. This fails when pytest is built with PEP 639 metadata (setuptools >= 77), because theLicenseheader no longer exists — it is replaced byLicense-Expression.Why upstream CI doesn't catch it
The dev dependencies pin
pytest==8.4.1, which was built with older setuptools and still has the legacyLicense: MITheader in its METADATA. The test only fails with pytest >= 9.0, which requiressetuptools>=77and emits PEP 639 metadata (License-Expression: MITwith noLicensefield).Any environment that doesn't use the pinned pytest version (e.g. nixpkgs, conda, other distros) hits this failure.
Fix
Use
.get()to checkLicense-Expressionfirst, then fall back toLicense. This handles both old-style and PEP 639 metadata:Using
.get()instead of[]also avoids theDeprecationWarningfromimportlib.metadataabout implicitNonereturns on missing keys, which will become aKeyErrorin a future Python version.